package borge.web.teamspirit.client.widgets;

import java.util.List;

import borge.web.teamspirit.client.TeamSpirit;
import borge.web.teamspirit.client.TeamSpiritConstants;
import borge.web.teamspirit.client.data.Serie;
import borge.web.teamspirit.client.interfaces.WidgetEventHandler;
import borge.web.teamspirit.client.interfaces.WidgetEventHandler.WidgetEventType;

/**
 * Display a list of series
 * @author andreas
 *
 */
@SuppressWarnings("unchecked")
public class ListSeriesWidget extends ListDataWidget<Serie> {
	
	//private List<Serie> iSeries;
	
	public ListSeriesWidget(WidgetEventHandler aEventHandler, List<Serie> aSeries){
		
	    super(aEventHandler, WidgetEventType.EDIT_SERIE, 
	            WidgetEventType.DELETE_SERIE,
	              WidgetEventType.SHOW_SERIE);
		iData = aSeries;

		// populate table with series information
		createDataTable();
		
		initWidget(iPanel);
		
	}
	
	protected void createDataTable(){
	    
	    reset();
        
        TeamSpiritConstants lcs = TeamSpirit.getConstants();
        int row = 0;
        int col = 0;

        // We should only show first name, second name, edit and delete later
  //      iTable.setText(row, col++, lcs.id());
        
        iTable.setText(row, col++, lcs.season());
        iTable.setText(row, col++, lcs.division());

        //iTable.setText(row, col++, lcs.edit());
        //iTable.setText(row, col++, lcs.delete());
        row++;

        for (Serie s : iData) {
            col = 0;

           // iTable.setText(row, col++, s.getSerieId().toString());
            //iTable.setText(row, col++, s.getSeason());
            //iTable.setText(row, col++, s.getDivision());
            addButtons(row, col);

            row++;
        }

        iPanel.add(iTable);
	}
	

}
